package com.geek.alert.handler;

import com.geek.alert.beans.AlertRule;
import com.geek.alert.beans.ApiStatInfo;
import com.geek.alert.beans.Notification;

public class TpsAlertHandler implements AlertHandler {
    @Override
    public void check(ApiStatInfo apiStatInfo, AlertRule alertRule, Notification notification) {
        long tps = apiStatInfo.getRequestCount() / apiStatInfo.getDurationOfSeconds();

        if (tps > alertRule.getMatchedRule(apiStatInfo.getApi()).getMaxTps()) {
            notification.notify("报警信息");
        }
    }
}